package IOStream;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/*
    字符流的写入流(输出流)
 */
public class WriterDemo {
    public static void main(String[] args) {
        File file=new File("c:\\IOStream\\writer.txt");
        FileWriter fw=null;
        BufferedWriter bw=null;
        try {
            fw=new FileWriter(file);
            bw=new BufferedWriter(fw);
            bw.write("hello");
            bw.write("world");
            bw.newLine();       //换行
            bw.append("hi");
            bw.flush();     //刷新缓冲区
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                fw.close();
                bw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
